package com.happycat.service.impl;
 
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.happycat.mobile.model.CommunityEntertainmentCategory;
import com.happycat.mobile.service.CommunityEntertainmentCategoryService;
import com.happycat.mapper.CommunityEntertainmentCategoryMapper;
import com.happycat.SysContants;
import com.happycat.ResponseModel;
import com.happycat.ResponseHeaderModel;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.happycat.Pagination;
/**
 * Module: CommunityEntertainmentCategory.java
 * 
 * @author liaoyong
 * @since JDK 1.8
 * @version 1.0
 * @date 2020-08-01
 * @Descriptions:
 */
@Service
public class CommunityEntertainmentCategoryServiceImpl extends ServiceImpl<CommunityEntertainmentCategoryMapper, CommunityEntertainmentCategory> implements CommunityEntertainmentCategoryService {
 		
 	public ResponseModel<CommunityEntertainmentCategory> selectOne(CommunityEntertainmentCategory communityEntertainmentCategory){
 		Wrapper<CommunityEntertainmentCategory> queryWrapper = new QueryWrapper<>(communityEntertainmentCategory);
		ResponseModel<CommunityEntertainmentCategory> responseModel = new ResponseModel<>();
		responseModel.setCode(SysContants.SYS_SUCCESS_CODE);
		responseModel.setMessage("查询成功");
		responseModel.setData(getOne(queryWrapper));
		return responseModel;
 	
 	}
	
	public ResponseHeaderModel	add(CommunityEntertainmentCategory communityEntertainmentCategory){
		ResponseHeaderModel responseHeaderModel = new ResponseHeaderModel();
		
		boolean result = save(communityEntertainmentCategory);
		if(result) {
			responseHeaderModel.setCode(SysContants.SYS_SUCCESS_CODE);
			responseHeaderModel.setMessage("新增成功");
		}else {
			responseHeaderModel.setCode(SysContants.SYS_FAIL_CODE);
			responseHeaderModel.setMessage("新增失败");
		}
		return responseHeaderModel;
	}
	
	public ResponseHeaderModel	modify(CommunityEntertainmentCategory communityEntertainmentCategory){
			ResponseHeaderModel responseHeaderModel = new ResponseHeaderModel();
		
		boolean result = updateById(communityEntertainmentCategory);
		if(result) {
			responseHeaderModel.setCode(SysContants.SYS_SUCCESS_CODE);
			responseHeaderModel.setMessage("修改成功");
		}else {
			responseHeaderModel.setCode(SysContants.SYS_FAIL_CODE);
			responseHeaderModel.setMessage("修改失败");
		}
		return responseHeaderModel;
	}
	
	public ResponseModel<Page<CommunityEntertainmentCategory>> pageList(Pagination<CommunityEntertainmentCategory>page){
		ResponseModel<Page<CommunityEntertainmentCategory>> responseModel = new ResponseModel<>();
		responseModel.setCode(SysContants.SYS_SUCCESS_CODE);
		responseModel.setMessage("查询成功");
		responseModel.setData(page(page,new QueryWrapper<CommunityEntertainmentCategory>(page.getEntity())));
		return responseModel;
	}
}
